package data.entity;

import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;

public abstract class Entity {
	
	protected Rectangle rec;
	protected boolean collision;
	protected int speed;
	private BufferedImage sprite;
	
	
	public Entity(int x, int y, int w, int h, BufferedImage s, int speed, boolean hasCollision){
		rec = new Rectangle(x,y,w,h);
		sprite = s;
		this.speed = speed;
		collision = hasCollision;
		
	}
	
	public Rectangle getRectangle(){
		return this.rec;
	}
	
	public void moveTop(long delta){
		rec.y = (int) (rec.y - (speed * (delta + 1)));
	}
	public void moveBot(long delta){
		rec.y = (int) (rec.y + (speed * (delta + 1)));
	}
	public void moveLeft(long delta){
		rec.x = (int) (rec.x - (speed * (delta + 1)));
	}
	public void moveRight(long delta){
		rec.x = (int) (rec.x + (speed * (delta + 1)));
	}
	
	public boolean hasCollision(){
		return collision;
	}
	
	public void setCollision(boolean collision){
		this.collision = collision;
	}
	
	public void render(Graphics g) {
		g.drawImage(sprite, rec.x, rec.y, null);
	}
	
	
	public int getSpeed(){
		return this.speed;
	}
}
